#include <stdio.h>

typedef unsigned long long BIG;

/*
 *  my solution: 20493418323 -> I would like to find the fail
 * the solution: 20492570929
 */

int main()
{
	const int SIZE = 50;

	// make sumarial table
	BIG** sumarial = new BIG*[SIZE/2+1];
	sumarial[0] = 0; sumarial[1] = 0, sumarial[2] = new BIG[SIZE];
	sumarial[2][0] = 0;
	for (int i = 1; i < SIZE; i++)
		sumarial[2][i] = sumarial[2][i-1] + i;

	for (int i = 3; i < SIZE/2+1; i++)
	{
		sumarial[i] = new BIG[SIZE];
		sumarial[i][0] = 0;
		for (int j = 1; j < SIZE; j++)
			sumarial[i][j] = sumarial[i][j-1] + sumarial[i-1][j];
	}

	// compute
	BIG result = sumarial[2][SIZE-1] - 1;
	for (int bSize = 2; bSize < SIZE; bSize++)
		for (int bNum = 2; bNum <= SIZE / bSize; bNum++)
			result += sumarial[bNum][SIZE-bNum*bSize+1];

	printf("Result: %llu", result);
	return 0;
}

/* Explicacion:

sumarial: como el factorial pero sumando.
representemoslo con el simbolo $

3$ = 3+2+1								sumarial[1][3]
3$$ = 3$ + 2$ + 1$ = 3+2+1 + 2+1 + 1	sumarial[2][3]

*/
